<?php
App::uses('AppComponent', 'Controller/Component');
App::uses('AppConst', 'Lib');

/**
 * Category Model
 *
 * @property 1 $1
 */
class Category extends AppModel {
	public $name = 'Category';
	/**
	 * Use database config
	 *
	 * @var string
	 */
	public $useTable = 'category';
	/**
	 * Display field
	 *
	 * @var string
	 */
	public $displayField = 'id';
    /**
	 * Get all user by condition
	 */
	public function getDataByCondition($field='*',$arrCondition=array()){
		$arrUser = array();
		try{
			$arrUser = $this->find('all', array(
                    'fields' => $field,
        			'conditions' => $arrCondition
			));
		}catch(Exception $ex){
			$this->log($ex->getMessage(),LOG_ERROR);
		}
		return $arrUser;
	}
    /**
	 * Function update mutil
	 *
	 * @author vunn
	 *
	 * @param $arrayData
     * @date 12/09/2012
     * 
	 * @return true or false
	 */
	function updateMutil($arrData=array()){
		if(empty($arrData))
            return false;
		$arrUpdate = array();
        
		foreach($arrData AS $item){
			$arrUpdate[] = array(
                    'Category' =>  $item
			);
		}
		return $this->saveMany($arrUpdate);
	}
}
